//
// Created by denglibin on 2021/5/28.
//

#ifndef SDL_DEMO_WINDOW_H
#define SDL_DEMO_WINDOW_H
#include <SDL.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>

typedef struct window{
    uint32_t  lastTime;
    uint32_t interval;
    SDL_Window * win; //窗口
    SDL_Surface * winSurface; //窗口的surface
    SDL_Renderer * winRender;//窗口渲染器
}Window;

typedef void Draw(Window*, SDL_Event*);
/**
 * 事件处理
 */
typedef void HandleEvent(Window*, SDL_Event*);
/**
 * 创建窗口对象
 * @param width
 * @param height
 * @param title
 * @return
 */
Window * createWindow(int width, int height, const char* title);

/**
 * 事件循环
 * @param window
 * @param draw
 * @param handleEvent 事件处理函数
 */
void eventLoop(Window* window, Draw* draw, HandleEvent* handleEvent );

/**
 * 释放空间
 * @param window
 */
void WindowFree(Window* window);
#endif //SDL_DEMO_WINDOW_H
